GBML manual / Arrays

array_max

Gives back the biggest number target has: array_max(scores) of 7, 3 and 9 is 9. Use it for the best score or the tallest tower.

Syntax

array_max(target) -> element

Arguments

NameType
targetarray

Returns

element

Description

Gives back the biggest number in target, an array. array_max(scores) of 7, 3 and 9 is 9. Use it for the best score or the tallest tower.

Example

var scores = array_create(3, 0);
scores[0] = 7;
scores[1] = 3;
scores[2] = 9;
var answer = array_max(scores);   // 9

The small print

Cost

One pass over the items.

On the GBA

One pass from the first item to the last, keeping the biggest seen so far - nothing is changed or copied. Whole numbers and decimals only; text, yes-or-no values, structs and references are refused when the project is checked. An empty one gives back 0.

See also: array_sortarray_minarray_sumlist_maxarray_lengthArraysData containers